package com.wwk.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.wwk.constant.MessageConstant;
import com.wwk.entity.Result;
import com.wwk.pojo.Setmeal;
import com.wwk.service.CheckMealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Classname SetmealController
 * @Description TODO
 * @Date 2020/11/5 20:39
 * @Created by com.wwk
 * @Author com.wwk
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {
    @Reference//(check = false)
    private CheckMealService mealService;

    //获取所有的套餐信息
    @RequestMapping("/getSetmeal")
    public Result getSetmeal(){
        try{
            List<Setmeal> list=mealService.findAll();
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    @RequestMapping("/findById")
    public Result findById(int id){
        try{
            Setmeal setmeal=mealService.findById(id);
            return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }
}
